﻿/// Write a program that reads two numbers N and K and generates all the combinations of K distinct elements from the set [1..N]. 
/// Example:	N = 5, K = 2  {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5}



using System;

class zad21
{
    static void Main()
    {
        int n = 5;
        int k = 2;
        int[] arr = new int[k];

        Combinations(arr, 0, 1, n);
    }

    static void Combinations(int[] array, int index, int currentNumber, int length)
    {
        if (index == array.Length)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(array[i] + " ");
            }
            Console.WriteLine();
        }
        else
        {
            for (int i = currentNumber; i <= length; i++)
            {
                array[index] = i;
                Combinations(array, index + 1, i + 1, length);
            }
        }
    }
}